package day20;

import java.io.File;

public class File04 {
    public static void main(String[] args) {
        File f = new File("aaa");
        boolean boolDel = Delete(f);
        System.out.println(boolDel);
    }

    private static boolean Delete(File file) {
        if (file.isFile()) {
            file.delete();
        }
        else if(file.isDirectory()&&file.listFiles().length==0) {
            file.delete();
        }
        else if (file.isDirectory()&&file.listFiles().length!=0) {
            for (File lF : file.listFiles()) {
                Delete(lF);
            }
            Delete(file);
        }

        if (!file.exists()) {return true;}
        else {return false;}
    }
}